<?php
	
	include 'Db.php';
	include 'Adapter/Interface.php';
	include 'Adapter/Abstract.php';
	include 'Adapter/Pdo/Abstract.php';
	include 'Adapter/Pdo/Mysql.php';
	
	$db = new Simplium_Db_Adapter_Pdo_Mysql(array(
		'host' => 'localhost',
		'dbname' => 'simplium',
		'username' => 'root',
		'password' => 'Yodanamus55',
		'charset' => 'UTF8'
	));
	
	
//	$db->query('
//		CREATE TABLE `users` (
//		  `id` INT(11) NOT NULL AUTO_INCREMENT,
//		  `name` VARCHAR(50) DEFAULT NULL,
//		  `email` VARCHAR(100) DEFAULT NULL,
//		  PRIMARY KEY (`id`)
//		) ENGINE=INNODB DEFAULT CHARSET=UTF8'
//	);
	
	// Insert
	$users = array(
		array('name' => 'Flamur', 'email' => 'fm@oxodesign.no'),
		array('name' => 'Fadion', 'email' => 'info@dmsagency.com'),
		array('name' => 'Jonian', 'email' => 'info@ishqip.com')
	);
	
	foreach($users as $user){
		$db->insert('users', $user);
	}
	
	// Select
	$q = $db->query('SELECT * FROM users WHERE name="Flamur"');
	$r = $q->fetch();
	
	echo '<pre>';
	print_r($r);
	/*
	 * Output:
		Array(
			[id] => 1
			[0] => 1
			[name] => Flamur
			[1] => Flamur
			[email] => fm@oxodesign.no
			[2] => fm@oxodesign.no
		)
	 */
	
	// Update
	$db->update('users', array('name' => 'Flamur Mavraj'), 'name = "Flamur"');
	$db->update('users', array('name' => 'Flamur E. Mavraj'), array('name LIKE ?' => 'Flamur%'));
	
	// Delete
	$db->delete('users', array('id = ?' => $r['id']));
	$db->delete('users', array('name = ?' => 'Fadion'));
	$db->delete('users', 'name = "Jonian"');